package com.vincent.transmitdemo;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MainTask implements Runnable{
    @Override
    public void run() {
        System.out.println(TransmitTest.threadLocal.get());
        for (int i = 0; i < 30; i++) {
            TaskInfo taskInfo = new TaskInfo();
            taskInfo.setId("hehe-"+ i);
            UserInfo userInfo = new UserInfo();
            userInfo.setUserName("vincent" + i);
            taskInfo.setUserInfo(userInfo);
            ContextHolder.set(userInfo);
            String parentValue = "hehe-"+ i;
            ExecutorService executorService = Executors.newFixedThreadPool(3);
            //executorService = TtlExecutors.getTtlExecutorService(executorService);
            executorService.execute(() -> {
                UserInfo myinfo  = (UserInfo) ContextHolder.get();
                System.out.println(myinfo.getUserName());
                LoggerUtil.log("xixi");
                //System.out.println(s + " :" + s.equals(parentValue));
            });
        }
    }
}
